//
//  RemoveFoodAlertView.m
//  ZooNgonDoiOS
//
//  Created by Trung sound on 8/27/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "RemoveFoodAlertView.h"
#import "UIImage+Crop.h"

@implementation RemoveFoodAlertView
@synthesize foodBean = _foodBean;

-(id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {

    }
    return self;
}

- (void)layoutSubviews {
    
    for (UIView *subview in self.subviews){ //Fast Enumeration
                                            //NSLog(@"subview class :%@",[subview class]); //Get Class Description of Each Subview
                                            //NSLog(@"subview.tag %i",subview.tag); //Get Button Tags
        
		if ([subview isMemberOfClass:[UIImageView class]]) { //Find UIImageView Containing Blue Background
			subview.hidden = YES; //Hide UIImageView Containing Blue Background
                                  // [subview removeFromSuperview]; Also Works
		}
        
		if ([subview isMemberOfClass:[UILabel class]]) { //Point to UILabels To Change Text
			UILabel *label = (UILabel*)subview;	//Cast From UIView to UILabel
                                                //			label.textColor = [UIColor colorWithRed:210.0f/255.0f green:210.0f/255.0f blue:210.0f/255.0f alpha:1.0f];
			label.shadowColor = [UIColor clearColor];
			label.shadowOffset = CGSizeMake(0, 0);
            label.textColor = [UIColor greenColor];
            label.font = [UIFont systemFontOfSize:18];
		}
        
        if ([subview isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)subview;
            button.titleLabel.font = [UIFont systemFontOfSize:15];
            [button setBackgroundImage:[UIImage imageNamed:IMG_VIEW_BACKGROUND] forState:UIControlStateNormal];
            
            [button setTitleColor:[UIColor whiteColor] forState:UIControlEventTouchUpInside];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
        }
	}
    [self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:IMG_VIEW_BACKGROUND]]];
}

- (void)drawRect:(CGRect)rect {
    _mainView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 284, 250)];
    [_mainView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:IMG_VIEW_BACKGROUND]]];
    
    _vFoodImage = [[HJManagedImageV alloc]initWithFrame:CGRectMake(22, 15, 240, 180)];

    NSURL *url = [NSURL URLWithString:@"http://family.go.com/images/cms/food/football-party-foods-240-j-5168841.jpg"];
    _vFoodImage.url = url;
    
    HJObjManager *objManager = [[HJObjManager alloc]initWithLoadingBufferSize:16 memCacheSize:20];
    [objManager manage:_vFoodImage];
    
    _lbFoodName = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, self.bounds.size.width, 35)];
    [_lbFoodName setText:_foodBean.foodName];
    [_lbFoodName setTextAlignment:UITextAlignmentCenter];
    [_lbFoodName setFont:[UIFont systemFontOfSize:16]];
    [_lbFoodName setBackgroundColor:[UIColor clearColor]];
    
    
    [_mainView addSubview:_vFoodImage];
    [_mainView addSubview:_lbFoodName];
    [self addSubview:_mainView];
}

@end
